<script setup lang='ts'>
import { onMounted, ref } from 'vue';
const myInputRef = ref(null)
const clickRef = ref(null)
// 想拿到ref进行操作只能在onMounted及其后面的钩子函数内或者是非同步操作中进行
onMounted(() => {
  // myInputRef.value.focus()
})
const clickMe = () => {
  myInputRef.value.focus()
}

</script>

<template>
  <div>
    <input ref="myInputRef">
    <button ref="clickRef" @click="clickMe">点我</button>
  </div>
</template>

<style scoped></style>